/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.gameshop.gui;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author MarcioMorando
 */
@Entity
@Table(name = "e003cadcomp", catalog = "mydb", schema = "")
@NamedQueries({
    @NamedQuery(name = "E003cadcomp.findAll", query = "SELECT e FROM E003cadcomp e"),
    @NamedQuery(name = "E003cadcomp.findByIdCompra", query = "SELECT e FROM E003cadcomp e WHERE e.idCompra = :idCompra"),
    @NamedQuery(name = "E003cadcomp.findByData", query = "SELECT e FROM E003cadcomp e WHERE e.data = :data"),
    @NamedQuery(name = "E003cadcomp.findByValortotalcompra", query = "SELECT e FROM E003cadcomp e WHERE e.valortotalcompra = :valortotalcompra"),
    @NamedQuery(name = "E003cadcomp.findByE001CadFornidFornecedor", query = "SELECT e FROM E003cadcomp e WHERE e.e001CadFornidFornecedor = :e001CadFornidFornecedor")})
public class E003cadcomp implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_Compra")
    private Integer idCompra;
    @Column(name = "data")
    @Temporal(TemporalType.DATE)
    private Date data;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "valortotalcompra")
    private Double valortotalcompra;
    @Basic(optional = false)
    @Column(name = "E001CadForn_id_Fornecedor")
    private int e001CadFornidFornecedor;
    @OneToMany(mappedBy = "e003CadCompidCompra")
    private List<E005itemcompra> e005itemcompraList;

    public E003cadcomp() {
    }

    public E003cadcomp(Integer idCompra) {
        this.idCompra = idCompra;
    }

    public E003cadcomp(Integer idCompra, int e001CadFornidFornecedor) {
        this.idCompra = idCompra;
        this.e001CadFornidFornecedor = e001CadFornidFornecedor;
    }

    public Integer getIdCompra() {
        return idCompra;
    }

    public void setIdCompra(Integer idCompra) {
        Integer oldIdCompra = this.idCompra;
        this.idCompra = idCompra;
        changeSupport.firePropertyChange("idCompra", oldIdCompra, idCompra);
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        Date oldData = this.data;
        this.data = data;
        changeSupport.firePropertyChange("data", oldData, data);
    }

    public Double getValortotalcompra() {
        return valortotalcompra;
    }

    public void setValortotalcompra(Double valortotalcompra) {
        Double oldValortotalcompra = this.valortotalcompra;
        this.valortotalcompra = valortotalcompra;
        changeSupport.firePropertyChange("valortotalcompra", oldValortotalcompra, valortotalcompra);
    }

    public int getE001CadFornidFornecedor() {
        return e001CadFornidFornecedor;
    }

    public void setE001CadFornidFornecedor(int e001CadFornidFornecedor) {
        int oldE001CadFornidFornecedor = this.e001CadFornidFornecedor;
        this.e001CadFornidFornecedor = e001CadFornidFornecedor;
        changeSupport.firePropertyChange("E001CadFornidFornecedor", oldE001CadFornidFornecedor, e001CadFornidFornecedor);
    }

    public List<E005itemcompra> getE005itemcompraList() {
        return e005itemcompraList;
    }

    public void setE005itemcompraList(List<E005itemcompra> e005itemcompraList) {
        this.e005itemcompraList = e005itemcompraList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCompra != null ? idCompra.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof E003cadcomp)) {
            return false;
        }
        E003cadcomp other = (E003cadcomp) object;
        if ((this.idCompra == null && other.idCompra != null) || (this.idCompra != null && !this.idCompra.equals(other.idCompra))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.gameshop.gui.E003cadcomp[ idCompra=" + idCompra + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
